package util;

import it.mrcrack.exception.DataFormatException;
import it.mrcrack.exception.DataNotFoundException;
import it.mrcrack.exception.SQLErrorCreation;

import java.io.IOException;
import java.sql.SQLException;

import model.util.Connessione;
import model.util.CreateTable;

public class Installation {
	public static void creaTabelle() throws DataFormatException, ClassNotFoundException, SQLException, SQLErrorCreation{
		Connessione conn=null;
		try {
			conn = new Connessione(Costanti.PATH_DATAFILE);
			CreateTable.CreateTableMeasureMonitor(conn);
		} finally {
			try {
				conn.getConn().close();
			} catch (SQLException e) {
				throw e;
			}
		}
	}

	public static void insSensori() throws ClassNotFoundException, SQLException, IOException, DataFormatException, DataNotFoundException{
		Connessione conn=null;
		try {
			conn = new Connessione(Costanti.PATH_DATAFILE);
			CreateTable.insSensori(conn, Costanti.PATH_SENSORCONFIGURATION);
		} finally {
			try {
				conn.getConn().close();
			} catch (SQLException e) {
				throw e;
			}
		}
	}
}
